package com.zjut.an.log.manager;

import java.util.List;

import javax.annotation.Resource;

import com.zjut.an.log.dao.AnLog;
import com.zjut.an.log.dao.AnLogDAO;
import com.zjut.an.util.module.PageModule;


public class AnLogManager {

	@Resource(name = "AnLogDAO")
	private AnLogDAO dao;
	
	public void addData(AnLog obj) {	
		dao.save(obj);
	}
	
	public void updateData(AnLog obj) {
		dao.update(obj);
	}
	
	public void deleteData(AnLog obj) {
		dao.delete(obj);
	}

	public void deleteDatas(List<AnLog> objllegeList) {
		for (AnLog AnLog : objllegeList) {
			dao.delete(AnLog);
		}
	}
	
	public PageModule getDataByInstance (int pageNumber,int pageSize, String sort, String order,AnLog obj) {
		return dao.findByInstance(pageNumber, pageSize, sort, order, obj);
	}
	
	public List getDatas() {
		return dao.findAll();
	}

	public AnLog getData(int objId) {
		return dao.findById(objId);
	}
	
	public String subIdcard(String idcard) {
		if (null!=idcard) {
			StringBuilder sb = new StringBuilder(idcard);
			sb.replace(4, idcard.length()-6, "****");
			return sb.toString();
		} else {
			return "";
		}		
	}
	
	public String subMobile(String mobile) {
		if (null!=mobile) {
			StringBuilder sb = new StringBuilder(mobile);
			sb.replace(4, mobile.length()-4, "***");
			return sb.toString();
		} else {
			return "";
		}		
	}
}
